﻿
@{
    ViewBag.Title = "TestFlow";
}

<div style="width:90%; margin: 0 auto;">
    <h2>申请</h2>
    标题：<input type="text" value="@ViewData["f1"]" style="width:80%;" id="f1" name="f1" />
    <br /><br />
    内容：<textarea id="f2" name="f2" style="width:80%; height:80px;">@ViewData["f2"]</textarea>
    <br /><br />
    <input type="button" value="保存" onclick="executeFlow('save');" />
    <input type="button" value="退回" onclick="back();" />
    <input type="button" value="发送" onclick="send();" />
</div>
<script>
    function send() {
        common.open('Send@(Html.Raw(Request.Url.Query))', 500, 300, "send");
    }
    function back() {
        common.open('Back@(Html.Raw(Request.Url.Query))', 500, 300, "back");
    }
    function executeFlow(type) {
        var data = { "flowid": "c540f280-5e40-4746-a64e-8cf70071c766", "type": type, "f1": $("#f1").val(), "f2": $("#f2").val() };
        $.ajax({
            url: "ExecuteFlow@(Html.Raw(Request.Url.Query))", data: data, type: "post", dataType:"json", success: function (json) {
                if (json.errcode != 0) {
                    alert(json.errmsg);
                }
                else {
                    var data = json.data;
                    alert(data.Messages);
                    if (data.IsSuccess) {
                        window.location = 'TestFlow?taskid=' + data.CurrentTask.Id + "&flowid=" + data.CurrentTask.FlowId
                            + "&groupid=" + data.CurrentTask.GroupId + "&instanceid=" + data.CurrentTask.InstanceId;
                    }
                }
            }
        });
    }
</script>